home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / groffvar.zoo / source / afmtodit.c next >
Encoding:
C/C++ Source or Header  |  1993-03-06  |  1.5 KB  |  47 lines

  1. /* grog.c - a replacement for the afmtodit perl script that comes         */
  2. /*           with the GNU distribution of groff 1.07                      */
  3. /* Written by Hildo Biersma on March 6, 1993                              */
  4. /* GNU public license applies - please see the file COPYING for details.  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <unistd.h>
  10. #include <limits.h>   /* For PATH_MAX */
  11. #include <support.h>  /* For findfile() and unx2dos() */
  12.  
  13. /* Note that, since the script name has an extension, findfile() */
  14. /* ignores these extensions for afmtodit.pl                      */
  15. char *extensions[] = {"ttp", "tos", "prg", NULL };
  16.  
  17. void main(int argc, char *argv[])
  18. {
  19.   char *ptr, **arg_vector, script[PATH_MAX + 1];
  20.   int  counter;
  21.  
  22.   /* Build the argument vector */
  23.   /* Note: arg_vector[0] and arg_vector[1] are filled in later */
  24.   if ((arg_vector = malloc(sizeof(char *) * (argc + 3))) == NULL)
  25.   {
  26.     fprintf(stderr, "%s: out of memory\n", argv[0]);
  27.     exit(1);
  28.   }
  29.   for (counter = 1; counter <= argc; counter++)
  30.     arg_vector[counter + 1] = argv[counter];
  31.  
  32.   /* Try to run perl */
  33.   ptr = findfile("afmtodit.pl", getenv("PATH"), extensions);
  34.   if (ptr != NULL)
  35.   {
  36.     unx2dos(ptr, script);
  37.     script[PATH_MAX] = 0x00;
  38.     arg_vector[1] = script;
  39.     arg_vector[0] = "perl";
  40.     execvp("perl", arg_vector);
  41.   }
  42.  
  43.   /* Give up */
  44.   fprintf(stderr, "%s: cannot find perl script or interpreter\n", argv[0]);
  45.   exit(1);
  46. } /* End of main() */
  47.